﻿package com.prototype.prototypepattern.deep;

import java.util.ArrayList;
/**
 * @Classname DeepCloneTest
 * @Description 深clone 测试
 * @Date 2019/11/22 0022 12:38
 * @Created by 埔枘
 */
public class DeepCloneTest{

    public static void main(String[] args) {

        QiTianDaSheng qiTianDaSheng = new QiTianDaSheng();
        qiTianDaSheng.setAge(18);
        qiTianDaSheng.setName("张一");
        ArrayList<String> list = new ArrayList<String>();
        list.add("桃子");
        list.add("🍌");

        qiTianDaSheng.setShuiguo(list);
        System.out.println(qiTianDaSheng.getAge());
        System.out.println(qiTianDaSheng.getName());
        System.out.println(qiTianDaSheng.getShuiguo());
        try {
            QiTianDaSheng clone = (QiTianDaSheng)qiTianDaSheng.clone();
            System.out.println(clone.getAge());
            System.out.println(clone.getName());
            System.out.println(clone.getShuiguo());

            System.out.println("深克隆：" + (qiTianDaSheng.getShuiguo() == clone.getShuiguo()));
        } catch (Exception e) {
            e.printStackTrace();
        }



    }
}
